
import 'package:flutter/material.dart';
import 'package:livan_log_tool/livan_log_tool.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            child: Row(
              children: [
                TextButton(
                  child: Text("保存"),
                  onPressed: () async {
                    final response = """
                      {"msg":"irure incididunt in","code":0,"data":[{"type":0,"typeName":"互动消息","buttonList":[{"id":"1001","name":"点赞","code":"1001","status":0,"userId":"1001"},{"id":"1002","name":"评论","code":"1002","status":0,"userId":"1001"},{"id":"1003","name":"新增关注","code":"1003","status":0,"userId":"1001"},{"id":"1004","name":"社区信息","code":"1004","status":0,"userId":"1001"}]},{"type":1,"typeName":"服务消息","buttonList":[{"id":"2001","name":"车辆信息","code":"2001","status":0,"userId":"1001"},{"id":"2002","name":"整车商城订单","code":"2002","status":0,"userId":"1001"},{"id":"2003","name":"番物商城订单","code":"2003","status":0,"userId":"1001"},{"id":"2004","name":"积分信息","code":"2004","status":0,"userId":"1001"}]}]}
                      """;
                    await LogManager.instance.writeLog(response);
                  },
                ),
              ],
            ),
          ),
          Container(
            child: Row(
              children: [
                TextButton(
                  child: Text("打印数据"),
                  onPressed: () async {
                  },
                ),
              ],
            ),
          ),
          Container(
            child: Row(
              children: [
                TextButton(
                  child: const Text("打印文件列表"),
                  onPressed: () async {
                    Navigator.pushNamed(context, "/log_list");
                  },
                ),
              ],
            ),
          ),
          Container(
            child: Row(
              children: [
                TextButton(
                  child: const Text("清理日志"),
                  onPressed: () async {
                    await LogManager.instance.clearLogs();
                  },
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}